<?php
class Application_Model_LoaiGioHoa extends Zend_Db_Table
{
	protected $_name='loaigiohoa';
	
	public function getAllLoaiGioHoa(){
		try{
			$sql = 'Select * From `loaigiohoa` where id != 6';
			$db = $this->_db;
			$db->setFetchMode ( Zend_Db::FETCH_ASSOC );
			$id = $db->fetchAll ( $sql );
			return $id;
		}catch(Exception $ex){
			echo "Can not get gio hoa, Error: ".$ex->getMessage();
			exit;
		}
	}
	
	public function getLoaiGioHoa($id)
	{
		$id = (int)$id;
		$row = $this->fetchRow('id = ' . $id);
		if (!$row) {
			throw new Exception("Khong tim thay loai gio hoa $id");
		}
		return $row->toArray();
	}//phuong thuc tra ve mot dong theo $id

	public function addLoaiGioHoa($tenloai)
	{
		$data = array(
				'tenloai' => $tenloai,
		);
		$this->insert($data);
	}//insert

	public function updateLoaiGioHoa($id,$tenloai)
	{
		$data = array(
				'tenloai'=>$tenloai,
		);
		$this->update($data, 'id = '. (int)$id);
	}//update

	public function deleteLoaiGioHoa($id)
	{
		$this->delete('id =' . (int)$id);
	}//drop
	
}